/*
A basic server that mimics an SMTP server
*/
var net = require('net');

function SmtpServer(port, host) {
    // default to port 25, host will already be defaulted to localhost by server.listen
    if (!port) port = 25;

    var _this = this;
    var server = net.createServer(function (socket) {
        socket.write('220 SMTP Service\r\n');
        _this.onClientConnected();
        socket.on('end', function () {
            _this.onClientDisconnected();
        });
        socket.on('data', function (data) {
            _this.onDataReceived(data);
            //socket.destroy()
            //server.close()
        })
    });
    // start listening
    server.listen(port, host, function () {
        // ?
    });
}

SmtpServer.prototype = {
    // basic event handlers
    onClientConnected: function () { },
    onClientDisconnected: function () { },
    onDataReceived: function (data) {
        socket.write('250 Hello\r\n');
    }
}

module.exports = SmtpServer;